#include <iostream>
#include <stdlib.h>
#include "Runway.h"
#include "Plane.h"
#include "random.h"

using namespace std;

void initialize(int &end_time,int &queue_limit,double &arrival_rate,
                double &departure_rate,Test_mode& mode);

int main()
{
    int end_time;
    int queue_limit;
    int flight_num = 0;
    double arrival_rate,departure_rate;
    Test_mode mode;
	random var;
    initialize(end_time,queue_limit,arrival_rate,departure_rate,mode);
    Runway small_airport(queue_limit, mode);
    for(int current_time = 0;current_time < end_time;current_time ++){
		int num_arrivals = var.poisson(arrival_rate);
        for(int i = 0;i < num_arrivals;i++){
            Plane current_plane(flight_num++,current_time,land);
            if(!small_airport.can_land(current_plane))
                current_plane.refuse();
        }
        int num_takeoff = var.poisson(departure_rate);
        for(int i = 0;i < num_takeoff;i++){
            Plane current_plane(flight_num++,current_time,takeoff);
            if(!small_airport.can_depart(current_plane))
                current_plane.refuse();
        }
        small_airport.activity(current_time);
    }

    return 0;
}

void initialize(int &end_time,int &queue_limit,double &arrival_rate,
				double &departure_rate,Test_mode& mode) {
	cout << "Input queue limit: ";
	cin >> queue_limit;
	cout << "Time units: ";
	cin >> end_time;
	cout << "Arrival_rate: ";
	cin >> arrival_rate;
	cout << "Departure_rate: ";
	cin >> departure_rate;
	cout << "Simulation mode: ";
	int i;
	cin >> i;
	mode = (enum Test_mode) i;
}
